﻿using System;

namespace Business
{
	public static class HelperClass
	{
		public static int StatusToInt(string str)
		{
			int returnvalue = 0;
			if (str.Equals("Normal"))
			{
				returnvalue = 1;
			}
			else if (str == "Caution")
			{
				returnvalue = 2;
			}
			else if (str == "Abnormal")
			{
				returnvalue = 3;
			}
			else if (str == "Severe")
			{
				returnvalue = 4;
			}
			else
			{
				returnvalue = 0;
			}
			return returnvalue;
		}

		public static string GetOilIconByStatusID(string statusID)
		{
			string src = "";

			if (statusID.Equals("4"))
			{
				src = "../images/oilsevere.png";
				return src;
			}
			else if (statusID.Equals("3"))
			{
				src = "../images/oilabnormal.png";
				return src;
			}
			else if (statusID.Equals("2"))
			{
				src = "../images/oilcaution.png";
				return src;
			}
			else if (statusID.Equals("1"))
			{
				src = "../images/oilnormal.png";
				return src;
			}
			else
			{
				src = "../images/oilna.png";
			}

			return src;
		}

		public static string GetVibartionIconByStatusID(string statusID)
		{
			string src = "";

			if (statusID.Equals("4"))
			{
				src = "../images/machine_red.png";
			}
			else if (statusID.Equals("3"))
			{
				src = "../images/machine_orange.png";
			}
			else if (statusID.Equals("2"))
			{
				src = "../images/machine_yellow.png";
			}
			else
			{
				src = "../images/machine_green.png";
			}
			return src;
		}

		public static string GetStringFromDate(DateTime dateTime)
		{
			if (dateTime == null || dateTime == default(DateTime))
			{
				return string.Empty;
			}
			else
			{
				return string.Format("{0}/{1}/{2}", dateTime.Day, dateTime.Month, dateTime.Year);
			}
		}
	}
}
